#pragma once


template<class iterator,class ref,class ptr> 
struct Reverse_iterator
{
	typedef Reverse_iterator<iterator, ref, ptr> self;

	iterator cur;

	Reverse_iterator(iterator it)
		:cur(it)
	{}

	ref& operator*()
	{
		iterator tmp(cur);
		--tmp;
		return *tmp;
	}

	ptr operator->()
	{
		return cur.operator->();
	}

	self& operator++()
	{
		--cur;
		return *this;
	}

	self operator++(int)
	{
		Reverse_iterator it(cur--);
		return it;
	}

	self operator--()
	{
		++cur;
		return *this;
	}

	self operator--(int)
	{
		Reverse_iterator it(cur++);
		return it;
	}

	bool operator!=(self it)
	{
		return cur != it.cur;
	}

	bool operator==(self it)
	{
		return cur == it.cur;
	}

};
